// https://leetcode.cn/problems/lemonade-change/
// Created by ade on 2022/8/17.
//
#include <iostream>
#include <algorithm>
#include <string>


using namespace std;

class Solution {
public:
    bool lemonadeChange(vector<int> &bills) {
        int c[3]; // 0-5 1-10 2-20
        for (auto i : bills) {
            if (i == 5) {
                c[0]++;
                continue;
            }
            if (i == 10) {
                c[0]--;
                if (c[0] < 0) return false;
                c[1]++;
                continue;
            }
            if (i == 20) {
                if (c[1] > 0) {
                    c[1]--;
                    c[0]--;
                } else {
                    c[0] = c[0] - 3;
                }
                if (c[0] < 0) return false;
            }
        }
        return true;

    }
};

int main() {

}